<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<button id="btn">click</button>
<script>
    const btn = document.getElementById('btn')

    function throttle(callback, delay) {
        let flag = true
        let timer = null
        if (!flag) return
        return function () {
            console.log(flag, timer);
            if (flag) {
                callback()
                flag = false
                timer = setTimeout(() => { flag = true }, delay)
            }
        }
    }

    function clickHandler() {
        console.log('Btn is clicked!')
    }

    btn.addEventListener('click', throttle(clickHandler, 3000))
</script>
</body>
</html>
